<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/5/17
 * Time: 15:05
 */

namespace Admin\Model;

use Think\Model;

class PaperModel extends Model{


    /**
     *获取试卷列表
     * @return mixed
     */
    public function getAll(){
        $res = $this->order('sort desc')->select();
        return $res;
    }


    /**添加
     * @param $data
     * @return string
     */
    public function addPaper($data){
        $flag = $this->add($data);
        if ($flag !== false) return '000000';
        return '111111';
    }

    /**修改
     * @param $data
     * @return string
     */
    public function editPaper($data){
        $flag = $this->save($data);
        if ($flag !== false )return '000000';
        return '111111';
    }

    /**
     * 删除
     * $data['id'] == 0 删除
     * @param $data
     * @return string
     */
    public function delPaper($data){
        $id = $data['id'];
        $this->where("id = $id")->delete();
        $flag = $this->delete($id);
        if ($flag !== false ) return '000000';
        return '111111';
    }

    /**是否存在此id
     * @param $id
     * @return string
     */
    public function getDelPaper($id){
        $flag = $this->delete($id);
        if ($flag !== false )return '000000';
        return '111111';
    }


    /**是否存在修改的ID
     * @param $data
     * @return mixed
     */
    public function getPaperById($data){
        $id = $data['id'];
        $result = $this->find($id);
        return $result;
    }



}